﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MentalAlchemy.Atomics;

namespace MentalAlchemy.Compounds.Image
{
	public delegate void ParametersChanged();
	
	public partial class GaborFilterParams : UserControl
	{
		#region - Delegate. -
		public ParametersChanged ParamChanged;
		#endregion

		#region - Public Properties. -
		/// <summary>
		/// Size of the Gabor filter mask.
		/// </summary>
		public Size MaskSize
		{
			get
			{
				return new Size((int)MaskSizeNumeric.Value, (int)MaskSizeNumeric.Value);
			}
		}
		/// <summary>
		/// Carrier horizontal frequency.
		/// </summary>
		public float HorizontalFrequency
		{
			get { return (float)HorFreqNumeric.Value; }
		}
		/// <summary>
		/// Carrier vertical frequency.
		/// </summary>
		public float VerticalFrequency
		{
			get { return (float)VertFreqNumeric.Value; }
		}
		/// <summary>
		/// Carrier phase.
		/// </summary>
		public float Phase
		{
			get { return (float)PhaseNumeric.Value; }
		}
		/// <summary>
		/// Parameters for the Gaussian envelope.
		/// </summary>
		public GaussianEnvelopeParameters GaussianEnvelope
		{
			get
			{
				var res = new GaussianEnvelopeParameters();
				res.Center = new PointF((float)CenterXNumeric.Value, (float)CenterYNumeric.Value);
				res.Angle = (float)AngleNumeric.Value;
				res.Magnitude = (float)MagNumeric.Value;
				res.ScaleXSqr = (float)ScaleXNumeric.Value;
				res.ScaleYSqr = (float)ScaleYNumeric.Value;
				return res;
			}
		}
		#endregion

		#region - Constructor. -
		public GaborFilterParams()
		{
			InitializeComponent();
		} 
		#endregion

		#region - Event handler. -
		private void ProcessParamChange(object sender, EventArgs e)
		{
			if (ParamChanged != null) ParamChanged();
		} 
		#endregion
	}
}
